package rodrigosetti.colorstrike.estados;

import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

import rodrigosetti.colorstrike.core.Constantes;
import rodrigosetti.midpgame.Estado;
import rodrigosetti.midpgame.GameCore;

public class Menu implements Estado {
	
	/* Sprites */
	private Image imagem;
	protected Sprite sprites[];
	public static final int NUM_MENUS = 3;

	public int atualizar() {
		return 0;
	}

	public void desenhar(Graphics g) {
	}

	public void finalizar() {
		imagem = null;
		sprites = null;
		System.gc();
	}

	public Estado getPai() {
		return null;
	}

	/**
	 * Carrega imagens
	 */
	public void inicializar() {
		GameCore.loading.inicializar(10);


		try {
			imagem = Image.createImage("/splash.png");
			GameCore.loading.atualizar();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		sprites = new Sprite[NUM_MENUS];
		
		for (int i = 0; i < NUM_MENUS; i++) {
			sprites[i] = new Sprite(imagem, Constantes.SPLASH_X, Constantes.SPLASH_Y);
			GameCore.loading.atualizar();
			sprites[i].setFrameSequence(Constantes.SEQ_SPLASH[i]);
			GameCore.loading.atualizar();			
			sprites[i].setPosition(GameCore.widthScreen/4,GameCore.heightScreen*(i+1)/5);
			GameCore.loading.atualizar();
		}

		/* Finaliza loading */
		GameCore.loading.finalizar();
	}

}
